<!-- table -->
				<div class="box">
					<!-- box / title -->
					<div class="title">
						<h5>
                            <?=$title;?>
                            <?php 
                                if($tomonth!='-')
                                    print month_name($month).' '.$year .' Dept .'.$dep;
                            ?>
                        </h5>
						<div class="search">
                            <?php if($tomonth=='-'): ?>
                            <?=form_open('cashflow/administrator/getBudgetDepartment')?>
								<div class="input">
                                    <?=form_dropdown('to_month',config('to_month'),'','style="width:60px"')?>
                                    <?=form_dropdown('month',config('month'),date('m'),$month)?>
								</div>
                                <div class="input">
									<?=form_dropdown('year',config('year'),date('Y'),$month)?>
								</div>
                                <div class="input">
									<?=form_dropdown('department',$departement,$dep,'style="width:120px"')?>
								</div>
                                <div class="input">
									<?=form_dropdown('type',config('type'),$type,'style="width:65px"')?>
								</div>
                                <div class="input">
                                    <?php if(empty($account))
                                         $account = '';
                                    ?>
									<?=form_dropdown('budget',$budget,$account,'style="width:120px"')?>
								</div>
								<div class="button">
									<input type="submit" name="submit" value="Search" />
								</div>
							<?=form_close()?>
                            <?php else:?>
                                <?=form_open('cashflow/administrator/getBudgetDepartmentExport')?>
								<div class="input">
                                    <label class="search"><?=lang('export')?></label>
									<?=form_dropdown('export',config('export'))?>
								</div>
								<div class="button">
									<?=form_submit('submit',lang('export'))?>
								</div>
							     <?=form_close()?>
                            <?php endif;?>
						</div>
					</div>
					<!-- end box / title -->
					<div class="table">
						<table>
							<thead>
								<tr>
									<th><?=lang('coa')?></th>
                                    <th><?=lang('ikhtisar')?></th>
                                    <th><?=lang('budget')?></th>
                                    <th><?=lang('planning')?></th>
                                    <th><?=lang('realitation')?></th>
                                    <th><?=lang('deviation')?></th>
                                    <th><?=lang('over')?></th>
                                    <th><?='(%)'?></th>
								</tr>
                                
							</thead>
                            <tbody>
                            <?php 
                            
                                //$anggaran=0;
                                $t3='';
                                $anggaranT3=0;
                                foreach($Accounts as $acc):?>
                            <?php //$data = $this->budgets->getBudgetSet($year,$month,'',$dep,'',substr($acc['NoUrut'],0,3)); ?>
                            <?php //if($data['AR']>0):?>
                                
                                <?php if(($acc['Jenis']=='H')):?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php endif;?>
                                
                                <?php if(($acc['Jenis']=='H1')):?>
                                <?php $dH1 = $this->budgets->getBudgetSet($year,$month,'',$dep,'',3,substr($acc['NoUrut'],0,3));?>
                                <?php if($dH1['AR']>0):?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php endif;?>
                                <?php endif;?>
                                
                                <?php if(($acc['Jenis']=='H2')):?>
                                <?php $dH2 = $this->budgets->getBudgetSet($year,$month,'',$dep,'',3,substr($acc['NoUrut'],0,3));?>
                                <?php if($dH2['AR']>0):?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php endif;?>
                                <?php endif;?>
                                
                                <?php if(($acc['Jenis']=='H3')):?>
                                <?php $dH3 = $this->budgets->getBudgetSet($year,$month,'',$dep,'',3,substr($acc['NoUrut'],0,3));?>
                                <?php if($dH3['AR']>0):?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php endif;?>
                                <?php endif;?>
                                
                                
                                <?php if(($acc['Jenis']=='D')):
                                    $budget =   $this->budgets->getBudgetSet($year,$month,$acc['MataAnggaran'],$dep);
                                    $cash   =   $this->cashflow->getBudgetCashflow($year,$month,$acc['MataAnggaran'],$dep);
                                    $over   =   $budget['tAnggaran'] - $cash['Credit'];  
                                    
                                    if($over!=0):
                                        $anggaran = $anggaran;
                                        $t3 = $over;
                                ?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></td>
                                    <td>
                                    <?php if(!empty($budget['tAnggaran'])): 
                                                echo decimal($budget['tAnggaran'],2);
                                                $a = $budget['tAnggaran']; 
                                          else:
                                                echo '0.00';
                                                $a=0;
                                          endif;            
                                                
                                          $anggaran = $anggaran + $a;    
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php if(!empty($budget['Anggaran'])): 
                                                echo decimal($budget['Anggaran'],2);
                                                $b = $budget['Anggaran'];
                                          else:
                                                echo '0.00';
                                                $b = 0;
                                          endif;  
                                          //$rencana = $rencana + $b;          
                                    ?>
                                    </td>
                                    
                                    <td class="right">
                                    <?php if(!empty($cash['Credit'])): 
                                                echo decimal($credit = $cash['Credit'],2);
                                                $c = $cash['Credit'];
                                          else:
                                                echo '0.00';
                                                $c = 0;
                                          endif;      
                                                
                                          //$realisasi=    $realisasi+$c;        
                                                
                                    ?>
                                    </td>
                                    
                                    <td class="right">
                                    <?php 
                                        $dev = $budget['Anggaran'] - $cash['Credit'];
                                        if(!empty($dev)):
                                            echo decimal($dev,2);
                                            $d = $dev;
                                        else:
                                            echo '0.00'; 
                                            $d = 0;
                                        endif;  
                                        //$deviasi =    $deviasi+$d;      
                                    ?>
                                    </td>
                                    
                                    <td class="right">
                                    <?php 
                                        if(!empty($over)):
                                            echo decimal($over,2);
                                        else:
                                            echo '0,00';
                                            $over = 0;
                                        endif; 
                                        //$over_budget = $over_budget + $over;       
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php 
                                        if(($acc['Jenis']=='D')):
                                            if($budget['tAnggaran']==0)
                                                $percent = 0;
                                            else
                                                $percent = ($cash['Credit']/$budget['tAnggaran'])*100;
                                        endif;
                                        
                                        if(!empty($percent))
                                            echo decimal($percent,2);
                                        else echo '0.00';      
                                    ?>
                                    </td>
                                
                                </tr>
                                
                                    
                                <?php 
                                    endif;
                                    endif;?>
                                
                                    
                                <?php if(($acc['Jenis']=='T3')):
                                        $anggaranT3 =  $anggaranT3 + $dH3['tAnggaran'];
                                        //$tot=
                                      
                                      if(($dH3['AR']>0) ):  
                                ?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td><?=decimal($anggaran,2);?></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php 
                                    endif;
                                    endif;?>    
                                
                                <?php 
                                if(($acc['Jenis']=='T2')):
                                      //$anggaranT2 = $dH2['tAnggaran'];
                                    //if($anggaran):
                                    if(($dH2['AR']>0) ):  
                                        
                                ?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td><?php //decimal($anggaran,2);?></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php 
                                
                                    endif;
                                    endif;?>
                                
                                <?php if(($acc['Jenis']=='T1')):
                                        $anggaran = $dH1['tAnggaran'];
                                    if($anggaran>0):    
                                ?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td><?=decimal($anggaran,2);?></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php 
                                    endif;
                                    endif;?>
                                
                            
                                <?php if(($acc['Jenis']=='TH')):?>
                                <tr>
                                    <td><?=$acc['NoUrut']?></td>
                                    <td><b><?=$acc['MataAnggaran'].'-'.$acc['Ikhtisar'].'-'.$acc['Jenis']?></b></td>
                                    <td>
                                        <?php
                                            $anggaranTH=$anggaranT3;
                                            print decimal($anggaranTH,2);
                                        ?>
                                    </td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php endif;?>
                                
                            <?php //endif;?>    
                            <?php 
                                endforeach;
                               
                                ?>
                            </tbody>
                       </table>     
                       
                       <?php if($tomonth!='-'):?>
                        <div class="action">
                            <?=anchor('cashflow/administrator/getBudgetDepartmentReset','Kembali Ke Awal');?>
			         	</div>
                        <?php endif;?>
                    	</div>
				</div>
				<!-- end table -->